<div class="weui-flex">
  <div class="weui-flex__item">
    <h2 class="d2-header">登陆</h2>
  </div>
</div>

<form #loginForm="ngForm">
  <div class="weui-cells weui-cells_form">
    <div class="weui-cell">
      <div class="weui-cell__hd"><label class="weui-label">用户名</label></div>
      <div class="weui-cell__bd">
        <input class="weui-input" type="text" minlength="4" maxlength="20" required placeholder="请输入用户名"
               [(ngModel)]="user.username" name="username">
      </div>
    </div>
    <div class="weui-cell">
      <div class="weui-cell__hd"><label class="weui-label">密码</label></div>
      <div class="weui-cell__bd">
        <input class="weui-input" type="password" placeholder="请输入密码(6-20位)" minlength="6" maxlength="20" required
               [(ngModel)]="user.password" name="password">
      </div>
    </div>
    <div class="weui-btn-area">
      <button class="weui-btn weui-btn_primary" *ngIf="loginForm.form.valid" (click)="submit()">确定</button>
      <button class="weui-btn weui-btn_plain-primary weui-btn_plain-disabled" *ngIf="!loginForm.form.valid">确定
      </button>
    </div>
  </div>
  <div class="register">
    <a (click)="registerPage()">没账户，去注册</a>
  </div>
</form>
<div *ngIf="errorFlag">
  <div class="weui-mask"></div>
  <div class="weui-dialog">
    <div class="weui-dialog__hd"><strong class="weui-dialog__title">{{errorTitle}}</strong></div>
    <div class="weui-dialog__bd">{{errorMsg}}</div>
    <div class="weui-dialog__ft">
      <a (click)="errorFlag = false" class="weui-dialog__btn weui-dialog__btn_primary">确定</a>
    </div>
  </div>
</div>

<div id="toast" *ngIf="successFlag">
  <div class="weui-mask_transparent"></div>
  <div class="weui-toast">
    <i class="weui-icon-success-no-circle weui-icon_toast"></i>
    <p class="weui-toast__content">登陆成功</p>
  </div>
</div>
